using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
	public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();
		}

		public Rectangle square = new Rectangle(0, 0, 50, 50);
		int ox, oy;

		private void drawWindow1_MouseDown(object sender, MouseEventArgs e)
		{
			ox = e.X - square.X;
			oy = e.Y - square.Y;
		}

		private void drawWindow1_MouseMove(object sender, MouseEventArgs e)
		{
			if (e.Button == MouseButtons.Left)
			{
				square.Location = new Point(e.X - ox, e.Y - oy);
				drawWindow1.Invalidate();
			}
		}

		private void drawWindow1_Paint(object sender, PaintEventArgs e)
		{
			e.Graphics.DrawRectangle(Pens.Blue, square);
		}
	}
}